TEntity
IdeaBlade DevForce 2010 Help Reference
FirstOrNullEntity<TEntity>(IQueryable<TEntity>,Expression<Func<TEntity,Boolean>>) Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityQueryExtensions Class > FirstOrNullEntity Method : FirstOrNullEntity<TEntity>(IQueryable<TEntity>,Expression<Func<TEntity,Boolean>>) Method



source1
predicate
Executes the query and returns the first element of the sequence, or the appropriate NullEntity if no element is found.

Syntax

Visual Basic (Declaration) 
<ExtensionAttribute()>
Public Overloads Shared Function FirstOrNullEntity(Of TEntity As Class)( _
   ByVal source1 As IQueryable(Of TEntity), _
   ByVal predicate As Expression(Of Func(Of TEntity,Boolean)) _
) As TEntity
Visual Basic (Usage)Copy Code
Dim source1 As IQueryable(Of TEntity)
Dim predicate As Expression(Of Func(Of TEntity,Boolean))
Dim value As TEntity
 
value = EntityQueryExtensions.FirstOrNullEntity(Of TEntity)(source1, predicate)
C# 
[ExtensionAttribute()]
public static TEntity FirstOrNullEntity<TEntity>( 
   IQueryable<TEntity> source1,
   Expression<Func<TEntity,bool>> predicate
)
where TEntity: class
C++/CLI 
[ExtensionAttribute()]
public:
static TEntity^ FirstOrNullEntitygeneric<typename TEntity>
( 
   IQueryable<TEntity^>^ source1,
   Expression<Func<TEntity^,bool>^>^ predicate
) 
where TEntity: ref class

Parameters

source1
predicate

Type Parameters

TEntity

Example

C#Copy Code
var mgr1 = new DomainModelEntityManager();
Customer cust = mgr1.Customers.FirstOrNullEntity(c => c.Country == "UK");

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.